package cn.com.idmy.auth.session.jwt;

import cn.com.idmy.auth.login.LoginState;
import cn.com.idmy.auth.session.SessionManager;
import cn.com.idmy.auth.session.SessionTokenManager;
import cn.com.idmy.auth.token.jwt.JwtTokenManager;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jetbrains.annotations.NotNull;

@Accessors(fluent = true)
@EqualsAndHashCode(callSuper = true)
public class JwtSessionTokenManager<ID> extends SessionTokenManager<ID> {
    protected final JwtTokenManager<ID> jwtTokenManager;

    public JwtSessionTokenManager(SessionManager<ID> sessionManager, JwtTokenManager<ID> jwtTokenManager) {
        super(sessionManager);
        this.jwtTokenManager = jwtTokenManager;
        jwtTokenManager.init();
    }

    @Override
    public @NotNull LoginState<ID> getState(@NotNull String token) {
        return jwtTokenManager.getState(token);
    }
}
